package com.axxy.adapter;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * @author 一缕茜阳
 * @date 2021/8/9
 */
public class EnumerationIterator implements Iterator {
    Enumeration enumeration;

    public EnumerationIterator(Enumeration enumeration) {
        this.enumeration = enumeration;
    }

    @Override
    public boolean hasNext() {
        return enumeration.hasMoreElements();
    }

    @Override
    public Object next() {
        return enumeration.nextElement();
    }

    public static void main(String[] args) {
        Enumeration enumeration = new Enumeration() {
            @Override
            public boolean hasMoreElements() {
                return true;
            }

            @Override
            public Object nextElement() {
                return null;
            }
        };
        Iterator iterator = new EnumerationIterator(enumeration);
        System.out.println(iterator.hasNext());
    }
}


